#include<stdio.h>
#include<unistd.h>
#include<sys/types.h>
int main(void)
{
    pid_t id=fork();
    if(id<0)//若创建进程失败
    {
        perror("fork");
        return 1;
    }//以下为成功创建进程
    else if(id==0)
    {
        //children process:
        while(1)
        {
            printf("I am child , pid:%d ; ppid:%d \n",getpid(),getppid());
            sleep(1);
        }
    }
    else 
    {
        //parent process:
        while(1)
        {
            printf("I am parent , pid:%d ; ppid:%d \n",getpid(),getppid());
            sleep(1);
        }
    }


    return 0;

}
